<template>
  <section class="app-container">
    <!-- 过滤条件 begin-->
    <el-form :inline="true" class="filter-container">
      <el-form-item label="订单号" prop="orderCode">
        <el-input v-model="searchForm.orderCode" placeholder="订单号" clearable></el-input>
      </el-form-item>
      <el-form-item label="时间段">
        <el-date-picker
          v-model="time"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button class="filter-item" type="primary" icon="el-icon-search" @click="onSearch">查询
        </el-button>
      </el-form-item>
      <el-form-item><slot></slot></el-form-item>
    </el-form>
    <!-- 过滤条件 end-->

    <!-- 表格 begin-->
    <el-table :data="list" style="width: 100%">
      <el-table-column prop="userId" label="用户id" min-width="90"></el-table-column>
      <el-table-column prop="orderCode" label="订单号" min-width="230"></el-table-column>
      <el-table-column prop="wxPayCode" label="微信交易号" min-width="230"></el-table-column>
      <el-table-column label="充值用户" min-width="180">
        <template slot-scope="props">
          <div class="middle">
            <m-img :src="props.row.head" ratio="1" style="width: 50px"/>
            <span class="ml6" style="line-height: 50px;display: inline-block">{{props.row.nick}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="充值金额" min-width="90">
        <template slot-scope="props">{{props.row.recodeMoney / 100}}元</template>
      </el-table-column>
      <el-table-column label="支付金额" min-width="90">
        <template slot-scope="props">{{props.row.payMoney / 100}}元</template>
      </el-table-column>
      <el-table-column prop="card" label="储值卡号" min-width="90"></el-table-column>
      <el-table-column label="时间" min-width="170">
        <template slot-scope="props">{{props.row.payDate | dataFormat}}</template>
      </el-table-column>
      <el-table-column label="状态" align="center" min-width="120">
        <template slot-scope="props">
          <el-tag v-if="props.row.state == 1">未支付</el-tag>
          <el-tag v-if="props.row.state == 2" type="warning">支付未充值</el-tag>
          <el-tag v-if="props.row.state == 3" type="success">支付已充值</el-tag>
          <el-tag v-if="props.row.state == 4" type="danger">申请退款</el-tag>
          <el-tag v-if="props.row.state == 5" type="warning">退款成功</el-tag>
          <el-tag v-if="props.row.state == 6" type="info">退款失败</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格 end-->

    <!--分页 begin-->
    <div class="pagination-container mt20">
      <el-pagination background @current-change="onPageChange" :current-page="searchForm.page" :page-size="limit"
                     layout="total, prev, pager, next, jumper" :total="total"></el-pagination>
    </div>
    <!--分页 begin-->

    <!--编辑 or 添加 弹窗 begin-->
    <el-dialog title="编辑" :visible.sync="dialogShow">
      <el-form ref="dataForm" :model="dataForm" label-position="left" label-width="70px"
               style='width: 400px; margin-left:50px;'>
        <el-form-item label="remark">
          <el-input placeholder="Please input" v-model="dataForm.input"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogShow = false">取消</el-button>
        <el-button type="primary" @click="onSubmit">确认</el-button>
      </div>
    </el-dialog>
    <!--编辑 or 添加 弹窗 begin-->
  </section>
</template>

<script>
  import {elValidate} from '@/utils/widget'
  import {timeMap} from '@/utils/widget'

  export default {
    data() {
      const {shiftId, shopId} = this.$route.query
      return {
        list: [],
        total: 0,
        limit: 0,
        listLoading: true,
        searchForm: {
          page: 1,
          shiftId,
          shopId,
          orderCode: null,
          date1: null,
          date2: null,
          page: 1
        },
        dialogShow: false,
        dataForm: {}
      }
    },
    computed: {
      time: timeMap('searchForm.date1', 'searchForm.date2')
    },
    created() {
      this.getList()
    },
    methods: {
      // 增
      add() {

      },
      // 删
      del() {

      },
      // 获取列表
      async getList() {
        //this.listLoading = true
        let {total, list, limit} = await this.$get_list('admin/payRecord/getPaycordByCondition', this.searchForm)
        Object.assign(this, {total, list, limit})
        document.documentElement.scrollTop = 0
      },
      // 更新数据
      update() {

      },
      // 搜索过滤
      onSearch() {
        this.searchForm.page = 1
        this.getList()
      },

      // 分页
      onPageChange(val) {
        this.searchForm.page = val
        this.getList()
      },

      onAdd() {
      },
      onDel() {
      },
      onUpdate() {
      },
      async onSubmit() {
        await elValidate(this, 'dataForm')
      }
    }
  }
</script>
<style type="text/scss" lang="scss" scoped>
  .form-preview {
    list-style: none;
    line-height: 40px;
    font-size: 15px;
    max-width: 880px;
    li {
      display: table;
      float: left;
      width: 33.33%;
    }
    span {
      display: table-cell;
    }
    span:first-child {
      width: 100px;
      color: #99a9bf !important;
    }
    span:last-child {
      //text-align: right;
      padding-right: 80px;
    }
  }
</style>
